from eDateTime import eDateTime

########################################################################
class eFileFilter:
    """Filter files with specific criteria"""
    
    #----------------------------------------------------------------------
    def olderThanXMinutes(self, fileList, fileSuffix, xMinutes):
        """Returnes list with filenames. Files are older than xMinutes"""
        oldFilesList = []
        
        for file in fileList:
            #remove the suffix and get a date
            date = file.replace(fileSuffix, '')
            if eDateTime().isOlderThanXMinutes(date, xMinutes):
                oldFilesList.append(file)
                
        return oldFilesList

#example           
#print eFileFilter().olderThanXMinutes(["2009-11-21-05:46:00-backup.tar", "2009-11-21-05:30:00-backup.tar"], "-backup.tar", 0)